<template>
  <div>
      <FormPanel ref="formPanel" :list="formList" :cols="1" :formType="'add'" labelWidth="100" :isSubmitBtn="false" @formChange="formChangeHandle" />
      <div style="padding-top: 1rem"></div>

    <BreakSpace label="错误信息" :containerStyle="{ marginBottom: '10px' }" />

     <FilterTable
      ref="table"
      :columns="columns"
      :dataSource="dataList"
      :datakey="'records'"
      :onColumnsChange="columns => (this.columns = columns)"
      :isPagination="false"
      :isSelectColumn="false"
      height="auto"
      :is-select-column="false"
    >
    </FilterTable>
          <div
        :style="{
          position: 'absolute',
          left: 0,
          right: 0,
          zIndex: 9,
          borderTop: '1px solid #e9e9e9',
          padding: '10px 20px',
          background: '#fff',
          textAlign: 'right',
        }"
      >
         <multiuse-button type="primary" :click="saveDialog.bind()">提 交</multiuse-button>
         <multiuse-button @click="closeDialog">关 闭</multiuse-button>
      </div>
  </div>
</template>
<script>
//import { batchByIds } from '@/api/claim/factory/AuthCheck';
import { dictionary } from '@/utils/dictMixin';
export default {
    mixins: [dictionary],
  data() {
    return {
      saveData:null,
      dataList: [],
      visible: false,
      collapse: false,
      selectedRows: [], //选中经销商
      formList: this.createFormList1(),
      columns: this.creatHeader(),

    };
  },
  created() {

  },
  methods: {
    formChangeHandle(val) {
      console.log(val);
      this.saveData = val;
    },
    //保存

 async saveDialog() {
      this.$refs.formPanel.SUBMIT_FORM();
      if (this.saveData !== null) {
     //把中文逗号换成英文逗号
      this.saveData.note = this.saveData.note.replaceAll(/，/g, ",");
        const res = await batchByIds(this.saveData);
        if (res.resultCode == 200) {
          if (res.data.length) {
            this.$notify.warning({ title: '提示信息', message: '有部分索赔单号错误,错误信息如下!' });
           //清空上次操作的数据
            this.$refs.table.$refs.pageTable.EXECUTE_DELETE(this.$refs.table.$refs.pageTable.list);
           //把返回的数据反显
            this.$refs.table.$refs.pageTable.EXECUTE_INSERT(res.data);
            //  this.$notify.error({ title: '提示信息', message: res.data.errorMsg });
          } else {
            this.$emit('save');
            this.$notify.success({ title: '提示信息', message: '保存成功' });
          }
        }
      }
    },
    closeDialog() {
      this.$emit('close', { visible: false, data: this.selectedRows, type: 'close' });
    },

    createFormList1() {
      return [
        {
          type: 'SELECT',
          label: '批量驳回',
          fieldName: 'reasonStatus',
          placeholder: '请选择状态...',
          filterable: true,
          itemList: [
            { text: '批量驳回', value:55031004 },
            { text: '撤销审核', value:55031003 },
          ],
          rules: [{ required: true, message: '请选择状态...', trigger: 'change' }],
        },
        {
          type: 'TEXT_AREA',
          label: '预授权单号',
          fieldName: 'authNos',
          initialValue: '',
          placeholder: '请输入预授权单号...',
          rules: [{required: true, message: '请输入预授权单号...', trigger: 'change'}],

        },
        {
          type: 'TEXT_AREA',
          label: '备注',
          fieldName: 'reasonRemarks',
          placeholder: '请输入备注...',
          rows: 2,
          rules: [{ required: true, message: '请输入备注...', trigger: 'blur' }],
        },

      ];
    },
    //table表头和数据源
    creatHeader() {
      return [
        { title: '错误单号', dataIndex: 'row', sorter: true },
        { title: '错误信息', dataIndex: 'errorMsg', sorter: true },
      ];
    },

  },
};
</script>

<style lang="less" scoped></style>
